package com.lib.common.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ViewFlipper;

/**
 * @author 一叶丶枫凌
 *         Created on 2017-04-05 15:11
 */
public class MyViewFlipper extends ViewFlipper {
	
	private OnViewFlipperListener mOnViewFlipperListener;

	public interface OnViewFlipperListener {

		void OnViewFlipper(View view, int position, int childCount);
	}

	public void setOnViewFilpperListener(OnViewFlipperListener listener) {

		mOnViewFlipperListener = listener;
	}

	public MyViewFlipper(Context context) {
		
		this(context, null);
	}
	
	public MyViewFlipper(Context context, AttributeSet attrs) {
		
		super(context, attrs);
	}

	@Override
	public void setDisplayedChild(int whichChild) {

		if (mOnViewFlipperListener != null) {
			mOnViewFlipperListener.OnViewFlipper(this, whichChild, getChildCount());
		}
		super.setDisplayedChild(whichChild);
	}
}